package com.woniuxy.controller;

import com.woniuxy.pojo.GoodsType;
import com.woniuxy.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("goodsType")
public class GoodsTypeController {

    @Autowired
    GoodsTypeService goodsTypeService;

    @GetMapping("/getGoodsTypes")
    public ResponseEntity<?> getGoodsTypes(){
        List<GoodsType> goodsTypes = goodsTypeService.getGoodsTypes();
        return ResponseEntity.ok(goodsTypes);
    }


    @GetMapping("/getTypeById/{id}")
    public ResponseEntity<?> getTypeById(@PathVariable Long id){

        String name = goodsTypeService.getTypeById(id);
        return ResponseEntity.ok(name);
    }
}
